package Models;

import java.rmi.RemoteException;
import java.util.LinkedList;

import listeners.CanPieceMoveListener;

public class StandardChessPieceModel implements ChessPieceModel {
	
	private boolean canJump = false;
	private boolean hasMove;
	private LinkedList<CanPieceMoveListener> canPieceMoveListeners = new LinkedList<CanPieceMoveListener>();
	
public StandardChessPieceModel() {
	hasMove = false;
}

@Override	
public void setMove(boolean hasMove) {
	this.hasMove = hasMove;
}

@Override
public boolean getMove() {
	return hasMove;
}

@Override
public void addCanPieceMoveListener(CanPieceMoveListener listener) {
	canPieceMoveListeners.add(listener);
}

@Override
public void removeCanPieceMoveListener(CanPieceMoveListener listener) {
	canPieceMoveListeners.remove(listener);
}

@Override
public boolean canPieceMoveNotify(Point2D from, Point2D to)
		throws RemoteException {
	
	for(CanPieceMoveListener listener : canPieceMoveListeners)
	{
		if(!listener.canPieceMoveNotify(from, to, this))
			return false;
	}
		
	return true;
}

@Override
public boolean canJump() {
	
	return canJump;
}

}
